import config from "../../config";
import { createSlice } from "@reduxjs/toolkit";

const sessionMenu = localStorage.getItem(config.SESSION_Menu)

const initMenu = sessionMenu ? sessionMenu : config.initMenu;
const initialState = {
  menu: initMenu,
};

export const themeSlice = createSlice({
  name: "menu",
  initialState,
  reducers: {
    setMenu(state, action) {
      state.menu = action.payload;
      localStorage.setItem(config.SESSION_Menu, action.payload);
    }
  },
});

export const { setMenu } = themeSlice.actions;

export default themeSlice.reducer;
